﻿@{
    ViewBag.Title = "FastEdit";
    Layout = "~/Views/Shared/_Iframe.cshtml";
}
@model MvcApplication.Entity.Post
@Scripts.Render("~/Content/kindeditor/kindeditor-all-min.js")
@Scripts.Render("~/Content/kindeditor/lang/zh_CN.js")
<div class="am-g" style="margin-top: 10px;">
    <form class="am-form am-form-horizontal" id="fastEditFormEl">
        <div class="am-form-group">
            <label for="doc-ipt-3" class="am-u-sm-2 am-form-label">标题</label>
            <div class="am-u-sm-10">
                <input type="hidden" name="id" value="@Model.ID">
                <input type="text" id="doc-ipt-3" placeholder="" name="title" value="@Model.Title">
            </div>
        </div>

        <div class="am-form-group">
            <label for="doc-ipt-pwd-2" class="am-u-sm-2 am-form-label">内容</label>
            <div class="am-u-sm-10">
                <textarea style="height:300px" rows="5" name="detail" id="detail">@Html.Raw(Model.Detail)</textarea>
            </div>
        </div>

        <div class="am-form-group">
            <div class="am-u-sm-offset-2 am-u-sm-10">
                <div class="checkbox">
                    <label>
                        <input type="checkbox">
                        记住十万年
                    </label>
                </div>
            </div>
        </div>

        <div class="am-form-group">
            <div class="am-u-sm-10 am-u-sm-offset-2">
                <input type="button" id="submitEl" class="am-btn am-btn-primary" value="保存" />
            </div>
        </div>
    </form>
</div>

<script>
    $('#submitEl').click(function () {
        var datas = $('#fastEditFormEl').serializeArray();
        console.log(datas);
        $.post('/post/savefastedit', datas).success(function () {
            //layer.confirm('新建成功', {
            //    btn: ['编辑这条文章', '新建', '关闭返回'] //按钮
            //}, function () {
            //    layer.msg('的确很重要', { icon: 1 });
            //}, function () {
            //    layer.msg('也可以这样', {
            //        time: 20000, //20s后自动关闭
            //        btn: ['明白了', '知道了']
            //    });
            //}, function () {
            //    layer.msg('也可以这样');
            //});
        }).error(function () {
            alert('服务器错误');
        });
    })

    KindEditor.ready(function (K) {
        window.editor = K.create('#detail', {
            width: '100%',
            height: '300px',
            uploadJson: '/image/index',
            items: ['wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent',
                    'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat',
                    'selectall', '|', 'baidumap', 'anchor', 'link', 'unlink', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat',
                    '|', 'image', 'multiimage', 'flash', 'insertfile', 'table', 'hr']
        });
    });
</script>
